package ajaxjs.data.entry.common_fields;

import ajaxjs.data.entry.type._String;

public class Cover extends _String {
	public String subQuery = "SELECT fileName FROM img WHERE img.parentId = {0}.id AND belongsTo = '{0}' LIMIT 1";
	
//	this.cover = new bf.Entity.String;
//	this.cover.label = '封面图';
//	this.cover.isRightJoinField = 'img.parentId = this.id ';
//	this.cover.as = 'fileName';
	
	public Cover(){
		this.label = "封面图";
	}
	
	/**
	 * 如果用户没有输入 intro，则自动读取标题作为 intro；如果以后有输入 intro，则读取 intro
	 * @return
	 */
	public String formatter(){
		String js = "if(!item)return;";
		js += "if(item.cover && item.cover.indexOf('http://') != -1)return;";
		js += "item.cover = !item.cover || item.cover == 'null' ? null : 'http://www.gdzjtv.net:8080/public/gallery/' + item.cover;" ;
		return js; 
	}
}
